<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'welcome.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  <%
	//System.out.println(session.getId());
  	String username=(String)session.getAttribute("username");
  	if(username==null||username==""){
  		out.println("<script>");
  		out.println("alert('您还没有登录！')");
  		out.println("window.location='login.jsp'");
  		out.println("</script>");
  	}
   %>
   <%
   String ip = request.getRemoteAddr();
   Object obj = application.getAttribute("num");
   Object oip = session.getAttribute("ip");
   int num = 1;
   if(obj == null){
   		application.setAttribute("num", num);
   		session.setAttribute("ip",ip);
   }else{
   		if(oip == null){
   			num = (Integer)obj;
   			num++;
   			application.setAttribute("num", num);
   			session.setAttribute("ip",ip);
   		}else{
   			num = (Integer)obj;
   			application.setAttribute("num", num);
   		}
   		
   }
    %>
  <body>
    <%=username %>，欢迎您登录！ <br/>
   	 您是第<%=num %>位访客<br/>
   	 您的IP是：<%=ip %><br/>
    <a href="logout.jsp">注销</a>
  </body>
</html>
